<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>WaitWindowEvent</title></head>
<body bgcolor="#EFF1F0" link="#3A3966" vlink="#000000" alink="#000000">
<font face="Verdana, sans-serif" size="2"><p align="center"><b><font size="4">WaitWindowEvent()</font></b></p>
<p><b>语法</b></p><blockquote>

Event = <font color="#3A3966"><b>WaitWindowEvent</b></font>([Timeout])    </blockquote>

</blockquote>
<b>概要</b><br><blockquote>



Wait until an event occurs. It's the same function as <a href="windowevent.html">WindowEvent()</a> 
but locks the program execution, which is very important in a multitasking 
environment. 

 

</blockquote><p><b>参数</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>Timeout (optional)</i></td>
<td width="90%"> 
 
The timeout (in milliseconds) which causes the function to 
return if no events are occurring. If no timeout is specified, it will wait 
infinitely until an event occurs. 

 

</td></tr>
</table>
</blockquote><p><b>返回值</b></p><blockquote>



Return the event which occurred, see <a href="windowevent.html">WindowEvent()</a> for more information. 

 

</blockquote><p><b>备注</b></p><blockquote>

An application should always use this function instead of <a href="windowevent.html">WindowEvent()</a> if possible, as it doesn't takes an CPU time while waiting for an event. <br><br>The window event loop should not be processed in a <a href="../thread/index.html">thread</a>, as there is some limitation on OS X and Linux. 调试器错误将被提高。<br><br>WaitWindowEvent() can only be called once per event loop, because else events will be "lost" (every event can only be processed once and isn't available anymore for a second time after first processing). 

</blockquote><p><b>Example:</b> General case</p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <b><font color="#3A3966">If</font></b> <font color="#3A3966">OpenWindow</font>(0, 0, 0, 230, 90, "Event handling example...", <font color="#924B72">#PB_Window_SystemMenu</font> | <font color="#924B72">#PB_Window_ScreenCentered</font>)

<font color="#3A3966">   ButtonGadget  </font>(1, 10, 10, 200, 20, "Click me")
<font color="#3A3966">   CheckBoxGadget</font>(2, 10, 40, 200, 20, "Check me")

   <b><font color="#3A3966">If</font></b> <font color="#3A3966">CreateMenu</font>(0,<font color="#3A3966"> WindowID</font>(0))
<font color="#3A3966">     MenuTitle</font>("Menu")
<font color="#3A3966">     MenuItem</font>(1, "Item 1")
<font color="#3A3966">     MenuItem</font>(2, "Item 2")
<font color="#3A3966">     MenuItem</font>(3, "Item 3")
   <b><font color="#3A3966">EndIf</font></b>

   <b><font color="#3A3966">Repeat</font></b>
     Event =<font color="#3A3966"> WaitWindowEvent</font>()
     
     <b><font color="#3A3966">Select</font></b> Event
     
       <b><font color="#3A3966">Case</font></b> <font color="#924B72">#PB_Event_Gadget</font>
         <b><font color="#3A3966">Select</font></b> <font color="#3A3966">EventGadget</font>()
           <b><font color="#3A3966">Case</font></b> 1 : <b><font color="#3A3966">Debug</font></b> "Button 1 clicked!"
           <b><font color="#3A3966">Case</font></b> 2 : <b><font color="#3A3966">Debug</font></b> "Button 2 clicked!"
         <b><font color="#3A3966">EndSelect</font></b>
       
       <b><font color="#3A3966">Case</font></b> <font color="#924B72">#PB_Event_Menu</font>
         <b><font color="#3A3966">Select</font></b> <font color="#3A3966">EventMenu</font>()
           <b><font color="#3A3966">Case</font></b> 1 : <b><font color="#3A3966">Debug</font></b> "Menu item 1 clicked!"
           <b><font color="#3A3966">Case</font></b> 2 : <b><font color="#3A3966">Debug</font></b> "Menu item 2 clicked!"
           <b><font color="#3A3966">Case</font></b> 3 : <b><font color="#3A3966">Debug</font></b> "Menu item 3 clicked!"
         <b><font color="#3A3966">EndSelect</font></b>
     
     <b><font color="#3A3966">EndSelect</font></b>
   <b><font color="#3A3966">Until</font></b> Event = <font color="#924B72">#PB_Event_CloseWindow</font>
 <b><font color="#3A3966">EndIf</font></b>
</font></pre>

</blockquote><p><b>Example:</b> With a TimeOut</p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <b><font color="#3A3966">If</font></b> <font color="#3A3966">OpenWindow</font>(0, 0, 0, 300, 30, "Position of the mouse on the desktop", <font color="#924B72">#PB_Window_SystemMenu</font> | <font color="#924B72">#PB_Window_ScreenCentered</font>)
<font color="#3A3966">    TextGadget</font>(0, 10, 6, 200, 20, "")
    
    <b><font color="#3A3966">Repeat</font></b>
      Event =<font color="#3A3966"> WaitWindowEvent</font>(20)
      
      <b><font color="#3A3966">If</font></b> Event = 0 <font color="#3A3966">; No more events in the queue, so let's display the mouse coordinates</font>
<font color="#3A3966">        SetGadgetText</font>(0, "Coordinates: " +<font color="#3A3966"> Str</font>(<font color="#3A3966">DesktopMouseX</font>()) + "," +<font color="#3A3966"> Str</font>(<font color="#3A3966">DesktopMouseY</font>()))
      <b><font color="#3A3966">EndIf</font></b>
       
    <b><font color="#3A3966">Until</font></b> Event = <font color="#924B72">#PB_Event_CloseWindow</font>
  <b><font color="#3A3966">EndIf</font></b>
</font></pre>

</blockquote><p><b>Example:</b> With a Timer</p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <b><font color="#3A3966">If</font></b> <font color="#3A3966">OpenWindow</font>(0, 0, 0, 300, 30, "Position of the mouse on the desktop", <font color="#924B72">#PB_Window_SystemMenu</font> | <font color="#924B72">#PB_Window_ScreenCentered</font>)
<font color="#3A3966">    TextGadget</font>(0, 10, 6, 200, 20, "")
<font color="#3A3966">    AddWindowTimer</font>(0, 0, 10) <font color="#3A3966">; Timeout = 10 ms</font>
    
    <b><font color="#3A3966">Repeat</font></b>
      Event =<font color="#3A3966"> WaitWindowEvent</font>()
      <b><font color="#3A3966">If</font></b> Event = <font color="#924B72">#PB_Event_Timer</font> <font color="#3A3966">; Each 10 ms =&gt; Let's display the coordinates</font>
<font color="#3A3966">      SetGadgetText</font>(0, "Coordinates: " +<font color="#3A3966"> Str</font>(<font color="#3A3966">DesktopMouseX</font>()) + "," +<font color="#3A3966"> Str</font>(<font color="#3A3966">DesktopMouseY</font>()))
      <b><font color="#3A3966">EndIf</font></b>
       
    <b><font color="#3A3966">Until</font></b> Event = <font color="#924B72">#PB_Event_CloseWindow</font>
  <b><font color="#3A3966">EndIf</font></b>
</font></pre>

</blockquote><p><b>参阅</b></p><blockquote>

<a href="windowevent.html">WindowEvent()</a>, <a href="eventwindow.html">EventWindow()</a>, 
<a href="eventgadget.html">EventGadget()</a>, <a href="eventmenu.html">EventMenu()</a>, 
<a href="eventtimer.html">EventTimer()</a>, <a href="eventdata.html">EventData()</a>, 
<a href="eventtype.html">EventType()</a>, <a href="postevent.html">PostEvent()</a>, 
<a href="bindevent.html">BindEvent()</a>, <a href="unbindevent.html">UnbindEvent()</a> 

</Blockquote><p><b>已支持操作系统 </b><Blockquote>所有</Blockquote></p><center>&lt;- <a href=unbindevent.html>UnbindEvent()</a> - <a href="index.html">Window Index</a> - <a href="windowbounds.html">WindowBounds()</a> -&gt;<br><br>

</body></html>